import { Project } from "@/api/interface/project";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 项目模板接口
 */

// 查询所有项目模板
export const getTemplateType = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/template/type`, params);
};

// 根据项目模板id查询标记为里程碑的模板任务
export const getTemplateMilestoneModel = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/template/milestoneModel`, params);
};

// 根据项目模板id查询模板任务
export const getTemplateTaskModel = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/template/taskModel`, params);
};

/**
 * @name 项目任务接口
 */

// 根据用户id获取所有子任务
export const getListAllSubtasksByUserId = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/project/task/listAllSubtasksByUserId`, params);
};
// 任务统计
export const getTaskStatistics = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/project/task/taskStatistics`, params);
};
// 查询任务管理
export const getTaskManagement = (params: Project.ReqProject) => {
  return http.post<Project.ResProjectData>(PORT1 + `/project/task/getTaskManagement`, params);
};
// 修改项目任务
export const updateProjectTask = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/task/update`, params);
};
// 添加项目任务
export const addProjectTask = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/task/add`, params);
};
//查询项目任务
export const getTaskDetail = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/project/task/detail`, params);
};
// 根据父任务查询子任务
export const getTaskByParentId = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/project/task/getTaskByParentId`, params);
};
// 删除项目任务
export const deleteProjectTask = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/project/task/delete`, params);
};

// 批量保存项目任务
export const saveProjectTaskSave = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/task/save`, params);
};

// 保存交付物信息
export const addProjectTaskSaveOutcomeInfo = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/task/saveOutcomeInfo`, params);
};
export const getTaskByProjectId = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/project/task/project_id`, params);
};
// 修改项目任务计划
export const updateProjectTaskPlan = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/task/update/plan`, params);
};

//查询全部项目编号和终端客户信息
export const getProjectListCode = () => {
  return http.get<Project.ResProjectData>(PORT1 + `/project/list/code`);
};

/**
 * @name 项目接口
 */

// 分页查询项目
export const getProjectPage = (params: Project.ReqProject) => {
  return http.post<Project.ResProjectData>(PORT1 + `/project/page`, params);
};

// 获取项目详情
export const getProjectDetail = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/project/detail`, params);
};

// 添加项目
export const addProject = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/add`, params);
};
// 编辑项目
export const updateProject = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/update`, params);
};
// 删除项目
export const deleteProject = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/project/delete`, params);
};

// 添加车辆
export const addProjectProduct = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/product`, params);
};
// 删除车辆
export const deleteProjectProduct = (params: Project.ReqProject) => {
  return http.delete(PORT1 + `/project/product`, params);
};
// 修改项目状态和状态描述
export const updateProjectStatus = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/status`, params);
};
// 修改项目硬件定制周期和信息H
export const updateProjectHardware = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/hardware`, params);
};
// 修改项目状态和状态描述
export const updateProjectSoftware = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/software`, params);
};
// 修改项目计划开始时间和结束时间
export const updateProjectPlanTime = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/planTime`, params);
};
// 更改用户ID（项目经理）
export const updateProjectUserId = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/userId`, params);
};

/**
 * @name 项目成员
 */

// 添加项目成员
export const addProjectUser = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/user/add`, params);
};
// 编辑项目成员
export const updateProjectUser = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/user/update`, params);
};
// 删除项目成员
export const deleteProjectUser = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/project/user/delete`, params);
};

// 添加项目成员（List）
export const addProjectUserList = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/user/addList`, params);
};

// 分页查询项目成员
export const getProjectUserPage = (params: Project.ResProjectData) => {
  return http.post<any>(PORT1 + `/project/user/page`, params);
};

// 根据项目id和人员类型查询项目成员信息
export const getProjectUserList = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/user/list`, params);
};
/**
 * @name 项目方案
 */
// 查询项目方案列表
export const getListProjectPlan = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/project/plan/listProjectPlan`, params);
};

// 查询项目方案历史
export const getListProjectPlanHistory = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/project/plan/listProjectPlanHistory`, params);
};

// 删除项目方案信息
export const deletePlan = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/project/plan/delete`, params);
};

// 添加项目方案信息
export const addProjectPlan = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/plan/add`, params);
};

// 查询项目方案信息
export const getProjectPlanDetail = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/project/plan/detail`, params);
};

/**
 * @name 项目附件
 */

// 分页查询项目文件信息
export const getProjectFilesPage = (params: Project.ReqProject) => {
  return http.post(PORT1 + `/project/files/page`, params);
};

// 添加项目文件信息
export const addProjectFile = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/files/add`, params);
};

// 删除项目方案信息
export const deleteFiles = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/project/files/delete`, params);
};

/**
 *批量添加订单文件信息
 */
export const addProjectFileBatch = (params: Project.ReqProject) => {
  return http.post(PORT1 + `/project/files/add/batch`, params);
};

/**
 * @name 项目日报
 */

// 分页查询项目日报
export const getReportPage = (params: Project.ReqProject) => {
  return http.post(PORT1 + `/report/page`, params);
};

// 添加日报
export const addReport = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/report/add`, params);
};

// 修改日报
export const updateReport = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/report/update`, params);
};
// 删除日报
export const deleteReport = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/report/delete`, params);
};

/**
 * @name 项目问题
 */

// 分页查询项目问题
export const getProjectProblemPage = (params: Project.ReqProject) => {
  return http.post(PORT1 + `/project/problem/page`, params);
};

// 添加问题
export const addProjectProblem = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/problem/add`, params);
};

// 修改
export const updateProjectProblem = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/problem/update`, params);
};
// 删除
export const deleteProjectProblem = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/project/problem/delete`, params);
};

// 根据用户查询未完结项目
export const getProjectList = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/project/list`, params);
};

// 查询最新50条问题

export const getProjectProblemTop50 = () => {
  return http.get(PORT1 + `/project/problem/top50`);
};

// 根据字段名修改项目问题

export const updateProjectProblemUpdateByField = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/problem/updateByField`, params);
};
// 修改项目问题图片
export const updateProjectProblemUpdateImg = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/problem/updateImg`, params);
};
// 查询最近12个月问题

export const projectProblemLast12Months = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/problem/last12Months`, params);
};
/**
 * @name 项目问题清单
 */

// 根据项目ID查询项目问题清单
export const getProjectProblemList = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/project/problem/list`, params);
};

// 添加项目问题清单（List）
export const getProjectProblemAddList = (params: Project.ReqProject) => {
  return http.post(PORT1 + `/project/problem/addList`, params);
};

// 添加项目问题清单(技术评审)（List）
export const getProjectProblemAddListTechnology = (params: Project.ReqProject) => {
  return http.post(PORT1 + `/project/problem/addListTechnology`, params);
};

//

/**
 * @name 项目BOM
 */

// 项目ID查询项目BOM
export const getProjectBomProject = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/project/bom/project`, params);
};

// 批量保存项目BOM
export const addProjectBomSaveBatch = (params: Project.ReqProject) => {
  return http.post(PORT1 + `/project/bom/saveBatch`, params);
};

/**
 * 项目检验表
 */
export const getProjectCheckDetail = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/project/check/detail`, params);
};

export const updateProjectCheckDetail = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/project/check/update`, params);
};

// 项目ID查询项目检验表
export const getProjectCheckDetailProject = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/project/check/detail/project`, params);
};

/**
 * 授权
 */

// 分页查询客户公司RDS授权
export const getCompanyAuthorizePage = (params: Project.ReqProject) => {
  return http.post(PORT1 + `/company/authorize/page`, params);
};
// 添添加客户公司RDS授权
export const addCompanyAuthorize = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/company/authorize/add`, params);
};

// 修改客户公司RDS授权
export const updateCompanyAuthorize = (params: Project.ResProjectData) => {
  return http.post(PORT1 + `/company/authorize/update`, params);
};
// 删除客户公司RDS授权
export const deleteCompanyAuthorize = (params: Project.ReqProject) => {
  return http.get(PORT1 + `/company/authorize/delete`, params);
};

// 查询客户公司RDS授权
export const getCompanyAuthorizeDetail = (params: Project.ReqProject) => {
  return http.get<Project.ResProjectData>(PORT1 + `/company/authorize/detail`, params);
};

// 查询全部项目编号和项目名称（包含老项目）
export const getProjectListCodeAll = () => {
  return http.get<Project.ResProjectData>(PORT1 + `/project/list/code/name`);
};
